<!DOCTYPE html>
<html lang="cn">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <link rel="icon" href="__PUBLIC__/imgs/icon/favicon.ico" type="image/ico" sizes="16x16">
    <link rel="icon" href="__PUBLIC__/imgs/icon/favicon.ico" type="image/ico" sizes="16x16">

    <title><{$title}></title>
    <link rel="stylesheet" href="__PUBLIC__/css/bootstrap.min.css">
    <link rel="stylesheet" href="__PUBLIC__/li.css">
    <!-- <link rel="stylesheet" href="__PUBLIC__/my.css"> -->
    <!-- <link rel="stylesheet" href="__PUBLIC__/question.css"> -->
    <!-- 预留块  引入个人css样式 -->
    <block name="mycss"></block>

</head>
<body class>
    <!-- 导航条开始 -->
        <nav class="navbar navbar-fixed-top navbar-default">
            <div class="container">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                        <!-- <span class="sr-only">Toggle navigation</span> -->
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <!-- 网页logo -->
                    <a class="navbar-brand" href="<{:U('Index/index')}>">
                        <img src="__PUBLIC__/imgs/icon/zhihu-logo.png" id="logo"> 
                    </a>
                </div>

                <!-- 导航条内容 content -->
                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                    <!-- 搜索框 -->
                    <form class="navbar-form navbar-left" name="searchform" action="<{:U('Search/index')}>" method="get" role="search">
                        <div class="form-group">
                          <input type="text" name="name" id="searchInput" class="form-control" placeholder="搜索你感兴趣的内容...">
                        </div>
                        <button type="submit" class="btn btn-default">
                            <span class="glyphicon glyphicon-search"></span>
                        </button>
                    </form>

                    <ul class="nav navbar-nav">
                        <li><a href="<{:U('Index/index')}>">首页</a></li>
                        <li><a href="<{:U('Topics/index')}>">话题</a></li>
                        <li><a href="<{:U('Explore/index')}>">发现</a></li>
                        <li>
                            <a href="<{:U('Inbox/index')}>">消息</a>
                            <!-- <a href="" id="nav_news">消息</a> -->
                        </li>
                    </ul>
                    
                  
                    <ul class="nav navbar-nav navbar-right">
                    <li>
                        <!-- 导航栏模态框控制 -->
                        <button style="margin-top:8px;" type="button" class="btn btn-primary " data-toggle="modal" data-target="#nav_ques_Model">
                            提 问
                        </button>
                    </li>

                    <notempty name="Think.session.home.name">
                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                <!-- 用户头像 记得修改成变量-->
                                <img src="__PUBLIC__/imgs/<{$Think.session.home.image}>" class="userimage">&nbsp;
                                <{$Think.session.home.name}>
                            </a>
                            
                            <ul class="dropdown-menu">
                                <li><a href="<{:U('People/index')}>">我的主页</a></li>
                                <li><a href="<{:U('Inbox/index')}>">私信</a></li>
                                <!-- <li><a href="<{//:U('Setting/index')}>">设置</a></li> -->
                                <li role="separator" class="divider"></li>
                                <li><a href="<{:U('Login/logout')}>">退出</a></li>
                            </ul>
                        </li>
                    <else/>
                        <li>
                            <a href="">注册知乎</a>
                                <{$Think.session.home.name}>
                        </li>
                        <li>
                            <a href="">登录</a>
                                <{$Think.session.home.name}>
                        </li>
                    </notempty>
                    </ul>
                </div><!-- /.navbar-collapse -->
            </div><!-- /.container-fluid -->
        </nav><!--结束导航条-->



<!-- 导航栏 消息下拉框 -->
    <!-- <div id="nav_news_box">
        <div> -->
            <!-- 导航标签 -->
            <!-- <ul class="nav nav-tabs" role="tablist" >
                <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">Home</a></li>
                <li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">Profile</a></li>
                <li role="presentation"><a href="#messages" aria-controls="messages" role="tab" data-toggle="tab">Messages</a></li>
                <li role="presentation"><a href="#settings" aria-controls="settings" role="tab" data-toggle="tab">Settings</a></li>
            </ul> -->

            <!-- 标签下的内容 -->
            <!-- <div class="tab-content">
                <div role="tabpanel" class="tab-pane active" id="home">.1</div>
                <div role="tabpanel" class="tab-pane" id="profile">..2</div>
                <div role="tabpanel" class="tab-pane" id="messages">.3.</div>
                <div role="tabpanel" class="tab-pane" id="settings">.4.</div>
            </div>
        </div>
    </div> -->

<!-- 导航栏提问模态框 -->
    <div class="modal fade" id="nav_ques_Model">
        <div class="modal-dialog">
            <form action="<{:U('index/addquestion')}>" method="post">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">提 问</h4>
                    </div>
                    <div class="modal-body">
                        <div id="asknotice">
                            <p class="h6" style="color:black">
                                知乎是一个真诚、友善、认真、互助的社区
                            </p>
                            <p class="h6" style="color:black">
                                我们希望每一个疑惑都有解答，好的问题更容易得到好答案  
                                <!-- <a href="<{}>">如何提一个好问题？</a> -->
                            </p>
                            <h5 style="color:black"><b>提问应遵循真实、客观、简洁、明确、规范的原则</b></h5>
                            <p class="h6" style="color:black">
                                1、提问应尽可能简洁明了，避免「请问」「有谁知道」「谢谢！」等与问题本身无关的附加语。
                                <br>
                                2、应避免使用「为神马」「童鞋」「肿么办」等网络用语。
                                <br>
                                3、基于个人判断或传言的问题，在提问时应在补充说明里详细说明原由
                                <br>
                                4、避免太宽泛问题，如调查性的问题容易变成每个人都可以发表观点，但对其他人没有价值。
                            </p>
                            <h5 style="color:black"><b>知乎禁止这些提问</b></h5>
                            <p class="h6" style="color:black">
                                1、和已有问题完全重复的问题，为避免重复，提问前可以先进行搜索
                                <br>
                                2、招聘 / 求职、交易 / 合作、寻人 / 征友、召集 / 赠送、求码类内容
                                <br>
                                3、投票类问题。例如：你支持方舟子还是韩寒？
                                <br>
                                4、作业或其他希望代为完成个人任务类的内容，以及针对个人具体病情的求医问药类问题
                                完整的提问建议可查看 
                                <!-- <a href="">知乎的提问规范有哪些？</a> -->
                            </p>
                            <h5 style="color:black"><b>提问前请先搜索</b></h5>
                        </div>
                        <input id="ask" type="text" name="name" class="form-control">
                        <div id="askreturn" class="col-md-12 askbefore"></div>
                        <div class="col-md-12 h6 text-center askbefore" id="reallyask">
                            不是,我要提一个新问题&gt;&gt;
                        </div>
                        <div class="clearfix"></div>
                    </div>
                    <div class="modal-footer">
                        <div class="mt10" id="askform">
                            <p class="h6 text-left" style="color:#000">问题说明(可选): </p>
                            <textarea class="form-control" name="content"></textarea>
                            <p class="h6 text-left" style="color:#000">选择话题(必选): </p>
                            <input type="text" id="topicin" name="topic_name" placeholder="请输入所属话题" class="form-control">
                            <div class="clearfix"></div>
                            <div id="topicout" class="text-left mt10"></div>
                            <p class="text-left">
                                <input type="checkbox" name="signed" value="1"> 匿名
                            </p>
                            <div class="mt10">
                                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                <button type="submit" class="btn btn-primary">发 布</button>
                            </div>
                        </div>
                    </div>
                </div><!-- /.modal-content -->
            </form>
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal 导航栏 提问模态框结束 -->

    <!-- 搜索展示页面 -->
    <div id="searchShow">
        <div class="container">
            <div class="row">
                <div class="col-md-12"></div>
            </div>
        </div>
    </div>



<!-- 文件主体部分 -->
<block name="main">
    <div class="container">
        <div class="row">
            <div class="col-md-10 col-md-offset-1">
                <!-- 主体 左部 -->
                <div class="col-md-9">
                    <!-- 主页个人动作区 -->
                    <div class="mt10">
                        <div class="w10 pull-left">
                            <img src="__PUBLIC__/imgs/<{$Think.session.home.image}>" class="pimage img-responsive">
                        </div>
                        <div class="w90 pull-left paction">
                            <div class="col-md-12">
                                <div></div>
                                <a href=""  data-toggle="modal" data-target="#nav_ques_Model"><span class="glyphicon glyphicon-question-sign"></span>
                                   &ensp;提问
                                </a>

                                <a href="<{:U('Question/index')}>">
                                    <span class="glyphicon glyphicon-list-alt"></span>
                                    &ensp;回答
                                </a>
                            
                                <a href="<{:U('Write/index')}>" >
                                    <span class="glyphicon glyphicon-pencil"></span>
                                    &ensp;写文章
                                </a>
                            </div>
                        </div>
                        <div class="clearfix"></div>
                    </div><!--个人操作区完成-->

                    <div class="mt30 row">
                        <div class="col-md-6 text-muted">
                            <span class="glyphicon glyphicon-th-list"></span>
                            <b>
                                &ensp;最新动态
                            </b>
                        </div>
                        <div class="col-md-6 h6 text-right ">
                            <!-- <a href="<{:U('Setting/filter')}>" class="text-muted">
                                <span class="glyphicon glyphicon-cog"></span>
                                &ensp;设置
                            </a> -->
                        </div>
                    </div>
                    <div class="divline"></div>

                    <if condition="$data eq null">
                        <div class="row mt20">
                            <!-- 无数据提示 -->
                            <div class="col-md-12">
                                <div class="col-md-12 text-center pget" style="border:1px solid #ccc;font-size: 12px; background-color: #eee">
                                    <p class="mt10">没有更多的关注信息!</p>
                                    <p>您可以通过关注更多 <a href="<{:U('Topics/index')}>"> 话题</a> , 来获取新的 <a href="<{:U('Index/index')}>">首页</a> 推荐.</p>
                                </div>
                            </div>
                        </div>
                    </if>

                    <!-- 首页推荐问题遍历 -->
                    <div class="row mt10">
                        <!-- 循环遍历数据 -->
                        <volist name="data" id="vo">
                            <!-- 每一个小块 -->
                            <div class="col-md-12 indexshow mt10">
                                <div class="w10 pull-left">
                                    <p>
                                        <a href="<{:U('Topics/detail','tid='.$vo['tid'])}>">
                                            <img src="__PUBLIC__/imgs/<{$vo.timage}>" class="img-responsive">
                                        </a>
                                    </p>
                                    <div>
                                        <div class="doclick">
                                            <!-- 预留 -->
                                        </div>
                                        <div >
                                            <!--预留-->
                                        </div>
                                    </div>
                                </div>
                                <div class="w90 pull-left">
                                    <div class="w100">
                                        <p class="h6 text-muted">
                                            来自话题: &nbsp;&nbsp;&nbsp;
                                            <a href="<{:U('Topics/detail','tid='.$vo['tid'])}>"><{$vo.tname}></a>
                                        </p>
                                        <p>
                                            <b >
                                                <a href="<{:U('Question/detail','qid='.$vo['qid'])}>">
                                                    <{$vo.qname}>
                                                </a>
                                            </b>
                                        </p>

                                        <!-- 判断回答信息如何, 不存在如下 -->
                                        <empty name="vo.aid">
                                            <p>
                                                <a href="<{:U('Answer/index','qid='.$vo['qid'])}>" class="h6" style="color:#000">暂无回答, 点此答题</a>
                                            </p>
                                        <!-- 判断回答信息的else区间 存在则显示回答 -->
                                        <else/>

                                            <p>
                                                <b >
                                                    <a href="<{:U('People/index','uid='.$vo['auid'])}>" class="h6" style="color:#000;">
                                                        <{$vo.auname}> &nbsp;&nbsp; 的回答
                                                        &nbsp;&nbsp;<{$vo.atime}>
                                                    </a>
                                                </b>
                                                <!-- <span class="h6 text-muted"><{$vo.qusay}></span> -->
                                            </p>
                                            <p class="h6" style="color: #000;">
                                                <a href="<{:U('Question/detail',array('qid'=>$vo['qid'],'aid'=>$vo['aid']))}>" style="color:#000"><{$vo.apart}>...</a>
                                                <!-- <a href="" showall="show" file="<{//$vo.afile}>">显示全部</a> -->
                                                <!-- <div>收起</div> -->
                                            </p>
                                            <!-- 问题显示下的用户操作连接 -->
                                            <p class="h6 text-muted " >
                                                <a href="" class="zan" zan="0" zannum="<{$vo.azan}>" question_id="<{$vo.qid}>" answer_id="<{$vo.aid}>" style="color:#666"><{$vo.azan}> 人赞同</a>&ensp;
                                                <a href="" class="discuss" discuss="0" answer_id="<{$vo.aid}>" page="1" style="color:#666" onclick="return showDiscuss(this)">
                                                    <span class="glyphicon glyphicon-check"></span><{$vo.adnum}>条评论
                                                </a> ·&ensp;
                                                <!-- <span class="otheraction">作者保留权利</span>&ensp; -->
                                                <span class="">
                                                    <a href="" class="thank" thank='0' question_id="<{$vo.qid}>" answer_id="<{$vo.aid}>" style="color:#666"><span class="glyphicon glyphicon-heart-empty"></span>感谢</a>&ensp;
                                                    <!-- <a href="" class="share" question_id="<{//$vo.qid}>" answer_id="<{//$vo.aid}>"><span class="glyphicon glyphicon-share"></span>分享</a>&ensp; -->
                                                    <!-- <a href=""  class="collect" question_id="<{$vo.qid}>" answer_id="<{$vo.aid}>" style="color:#666"><span class="glyphicon glyphicon-paperclip"></span>收藏</a> ·  -->
                                                    <a href=""  class="helpless" question_id="<{$vo.qid}>" answer_id="<{$vo.aid}>" style="color:#666">没有帮助</a> · 
                                                    <a href=""  class="report" question_id="<{$vo.qid}>" answer_id="<{$vo.aid}>" style="color:#666">举报</a> · 
                                                    <!-- <a href=""> -->
                                                        <span class="">作者保留权利</span>
                                                    <!-- </a> -->
                                                </span>
                                            </p>
                                            <!-- 答案评论显示 -->
                                            <div id="dis<{$vo.aid}>" class="col-md-12" style="display:none; border:1px solid #ccc">
                                            </div>

                                        </empty>
                                        <!-- 判断回答为空否 结束 -->

                                        <!-- 关注问题 -->
                                        <p class="h6 text-muted ">
                                            <a href="" class="attend" question_id="<{$vo.qid}>"><span class="glyphicon glyphicon-plus"></span>关注问题</a>&ensp;
                                        </p>

                                    </div>
                                </div>

                                <div class="clearfix"></div>
                                <div class="divline"></div>
                            </div>
                        </volist>
                    </div><!-- 推荐问题结束 -->
                    <!-- 遍历循环结束  -->
                    <!-- 预留位置  -->

                    <div class="row">
                        <div class="col-md-12 mt20">
                            <a href="<{:U('Index/index', 'p='.$p)}>" class="btn btn-default btn-sm col-md-12 indexShowMore" p="2"> 查看更多 </a>
                        </div>
                        <div class="clearfix"></div>
                        <div class="mt20"></div>
                    </div>

                </div><!-- 主体左部结尾 -->


                <!-- 主体 右部 -->
                <div class="col-md-3">

                    <div class="h6 rightshow">
                        <a href="<{:U('Index/index')}>"  style="color:#888"><span class="glyphicon glyphicon-home"></span>&nbsp;&nbsp;知乎首页</a>

                        <a href="<{:U('Collections/index')}>"  style="color:#888"><span class="glyphicon glyphicon-bookmark"></span>&nbsp;&nbsp;我的收藏</a>

                        <a href="<{:U('Question/following')}>"  style="color:#888"><span class="glyphicon glyphicon-check"></span>&nbsp;&nbsp;我关注的问题</a>

                        <a href="<{:U('Topics/index')}>" style="color:#888"><span class="glyphicon glyphicon-th-large"></span>&nbsp;&nbsp;话题广场</a>

                    </div>

                    <h5 class="mt30"> <b><img src="__PUBLIC__/images/2016-07-21_141413.jpg">&nbsp;&nbsp;知乎专栏</b> </h5>
                    <div class="h6 rightshow">
                        <a href="<{:U('Explore/index')}>"  style="color:#888">发现</a>
                        <a href="<{:U('Article/index')}>"  style="color:#888">文章</a>
                    </div>
                    <div >© 2016 知乎</div>
                    
                </div>
            </div>
        </div><!--row 结束-->
    </div><!-- container 结束 -->
</block>
<!--   结束   文件主体部分 -->




    <!--引入jquery-->
    <script src="__PUBLIC__/js/jquery.min.js"></script>
    <!--引入bootstrap 的js-->
    <script src="__PUBLIC__/js/bootstrap.min.js"></script>
    <!-- 自定义js -->
    <script type="text/javascript">
        $(function(){

            // 首页搜索栏的问题输入搜索js
            $('#searchInput')[0].oninput = searchthing;
            $('#searchInput')[0].onpropertychange = searchthing;
            // 只查询 问题表
            function searchthing(){
                var name = this.value;
                // console.log(name);
                if (name == '') {
                    $('#searchShow').hide();
                } else {
                    // $('#searchShow').empty(); // 清内容
                    //给位置
                    $('#searchShow').css({
                        left : function(){
                            return $('#searchInput').offset().left;
                        },
                        top : function(){
                            return $('#searchInput').offset().top + 55;
                        }
                    });

                    // 获取url
                    // var url = window.location.pathname;
                    // console.log(url);
                    // var path = url.substr(0,9)
                    var path = '';

                    $.ajax({
                        type: 'get',
                        url: "<{:U('Home/index/searchinfo')}>",
                        data: 'name='+name,
                        dataType: "json",
                        success: function(msg){
                            // console.log(msg);
                            var list = eval(msg);
                            // console.log(list[0]);

                            // 拼接字符串
                            var str = '';
                            if (list[0].length != 0) {
                                str += '<p>查询到以下相关用户: </p>';
                                for (var i = 0; i < list[0].length; i++) {
                                    str += '<div class="mt10"><div class="w10 pull-left"><a href="'+path+'/Home/People/index/uid/'+list[0][i].id+'"><img src="/Public/imgs/'+list[0][i].image+'" style="width:20px; height:20px;"></a></div><div class="w90 pull-right"><a href="/Home/People/index/uid/'+list[0][i].id+'">'+list[0][i].name+'</a></div><div class="clearfix"></div></div>';
                                };
                            };
                            if (list[1].length != 0) {
                                str += '<p class="mt10">查询到以下相关文章: </p>';
                                for (var i = 0; i < list[1].length; i++) {
                                    str += '<div class="mt10"><a href="/Home/Article/show/arid/'+list[1][i].id+'">'+list[1][i].title+'</a></div>';
                                };
                            };
                            if (list[2].length != 0) {
                                str += '<p class="mt10">查询到以下相关问题:</p>';
                                for (var i = 0; i < list[2].length; i++) {
                                    str += '<div class="mt10"><a href="/Home/Question/detail/qid/'+list[2][i].id+'">'+list[2][i].name+'</a></div>';
                                };
                            };
                            // console.log(str);
                            
                            $('#searchShow .row').html(str);
                            // $('#searchShow .row').html(str);
                            $('#searchShow').show();
                        },
                    });// ajax 结束
                }; //if判断结束
            };//searchthing() 结束

            // news 消息框弹出
            $('#nav_news').click(function(){
                // console.log($('#nav_news').offset().left);
                // console.log($('#nav_news').offset().top);
                $('#nav_news_box').css({
                    left : function(){
                        return $('#nav_news').offset().left;
                    },
                    top : function(){
                        return $('#nav_news').offset().top + 55;
                    }
                });
                $('#nav_news_box').toggle();
                return false;
            });

            // 提问模态框的问题输入搜索js
            $('#ask')[0].oninput = askthing;
            $('#ask')[0].onpropertychange = askthing;
            // 只查询 问题表
            function askthing(){
                var qname = this.value;
                // console.log(qname);
                if (qname == '') {
                    $('#askreturn').empty();
                } else{
                    $.ajax({
                        type: 'get',
                        url: "<{:U('Home/index/ask')}>",
                        data: 'name='+qname,
                        // dataType: "json",
                        success: function(msg){
                            var texta = '';
                            $('#askreturn').html(texta+msg);
                        },
                    });// ajax 结束
                    $('#reallyask').show();
                }; //if判断结束
            };//askthing() 结束


            // 提问模态框的话题检索
            $('#topicin')[0].oninput = chooseTopic;
            $('#topicin')[0].onpropertychange = chooseTopic;
            function chooseTopic(){
                var topicName = this.value;
                console.log(topicName);
                if (topicName == '') {
                    $('#topicout').empty().hide();
                } else{
                    $.ajax({
                        type: 'get',
                        url: "<{:U('Home/Index/gettopic')}>",
                        data: 'name='+topicName,
                        dataType: "json",
                        success: function(msg){
                            var data = eval(msg);
                            var str ='<div class="col-md-12 h6"><p>相关的话题如下: 填写已有的话题才能提交问题!</p><p>如此处没有您要找的内容,可以<a href="<{:U("Topics/index")}>">前往话题广场浏览话题</a></p></div>';
                            for (var i = 0; i < data.length; i++) {
                                // console.log(data[i].id)
                                // console.log(data[i].name)
                                str += '<p topicid="'+data[i].id+'" style="cursor:pointer">'+data[i].name+'</p>';
                            };
                            console.log(str)
                            $('#topicout').html(str).css('border','1px solid #aaa').show();
                        },
                    });// ajax 结束
                }; //if判断结束
            };//chooseTopic() 结束

            // 确定提问,编辑问题点击事件
            $('#reallyask').click(function(){
                $('#asknotice').hide();
                $(this).hide();
                $('#askform').show();
            });// 提问点击事件结束

            // 导航条搜索 框 事件
            // 
            
            $('.thank').click(function(){
                if ($(this).text() == '感谢') {
                    $(this).text('取消感谢');
                }else{
                    $(this).text('感谢');
                };
                return false;
            })
            
            // 关注问题 的触发事件(群体)
            var qattend = $('a.attend');
            for (var i = 0; i < qattend.length; i++) {
                $(qattend[i]).click(function(){
                    // console.log($(this));
                    var qid = $(this).attr('question_id')
                    // 判断a标签是关注还是否
                    if ($(this).text() == '关注问题') {
                        $.ajax({
                            type: 'get',
                            url: "<{:U('Index/guan')}>",
                            data: 'qid=' + $(this).attr('question_id'),
                        });
                        $(this).text('取消关注');
                    } else {
                        $.ajax({
                            type: 'get',
                            url: "<{:U('Index/quguan')}>",
                            data: 'qid=' + $(this).attr('question_id'),
                        });
                        $(this).html('<span class="glyphicon glyphicon-plus">关注问题');
                    };
                    return false; //阻止跳转
                });
            }; // 关注问题点击事件结束


            // 赞同的触发事件
            var answerZan = $('a.zan');
            for (var i = 0; i < answerZan.length; i++) {
                $(answerZan[i]).click(function(){
                    // console.log($(this));
                    var qid = $(this).attr('answer_id');
                    var zannum = $(this).attr('zannum');
                    var addzan = parseInt(zannum) + 1;

                    if ($(this).attr('zan') == '0') {
                        $.ajax({
                            type: 'get',
                            url: "<{:U('Index/zan')}>",
                            data: 'aid=' + $(this).attr('answer_id'),
                        });
                        $(this).attr('zan', '1');
                        $(this).html((parseInt(zannum) + 1) + '人赞同');
                    } else {
                        $.ajax({
                            type: 'get',
                            url: "<{:U('Index/quzan')}>",
                            data: 'aid=' + $(this).attr('answer_id'),
                        });
                        $(this).attr('zan', '0');
                        $(this).html( zannum + '人赞同');
                    };
                    return false; //阻止跳转
                });
            }; // 赞同回答点击事件结束

            // 感谢触发事件
            var answerThank = $('a.thank');
            for (var i = 0; i < answerThank.length; i++) {
                $(answerThank[i]).click(function(){
                    // console.log($(this));
                    var qid = $(this).attr('answer_id');
                    if ($(this).attr('thank') == '0') {
                        console.log($(this).attr('thank'));
                        $.ajax({
                            type: 'get',
                            url: "<{:U('Index/thank')}>",
                            data: 'aid=' + $(this).attr('answer_id'),
                        });
                        $(this).attr('thank', '1');
                        $(this).html('-已感谢-');
                    }
                    return false; //阻止跳转
                });
            }; // 感谢回答点击事件结束

            // 举报触发事件
            var answerReport = $('a.report');
            for (var i = 0; i < answerReport.length; i++) {
                $(answerReport[i]).click(function(){
                    if ($(this).html() == '举报') {
                        // console.log($(this).html());
                        if (confirm('你确定要举报该回答?') == true) {
                            $(this).html('-已举报-');
                            $.ajax({
                                type: 'get',
                                url: "<{:U('Index/report')}>",
                                data: 'aid=' + $(this).attr('answer_id'),
                            });
                        }
                    }
                    return false; //阻止跳转
                });
            }; // 举报触发事件结束

            // 没有帮助
            var answerHelpless = $('a.helpless');
            for (var i = 0; i < answerHelpless.length; i++) {
                $(answerHelpless[i]).click(function(){
                    if (confirm('你确定此回答没有帮助?') == true) {
                        if ($(this).html() == '没有帮助') {
                            $.ajax({
                                type: 'get',
                                url: "<{:U('Index/helpless')}>",
                                data: 'aid=' + $(this).attr('answer_id'),
                            });
                            $(this).html('-无帮助已提交-');
                        }
                    }
                    return false; //阻止跳转
                });
            }; // 无帮助触发事件结束



        });  // jquery 结束符号



        // 原生js部分
        //答案下的评论原生js
        //
        function showDiscuss(disA){
            var aid = disA.getAttribute('answer_id'); 
            var page = disA.getAttribute('page');
            var disdiv = document.getElementById('dis'+ parseInt(aid));
            console.log(disdiv);
            console.log(page);
            console.log(aid);
            if (disdiv.style.display == 'none') {
                var xhr = new XMLHttpRequest();
                //回调
                // console.log();
                xhr.onreadystatechange = function(){
                    if (xhr.status == 200 && xhr.readyState == 4) {
                        // console.log(xhr.responseText);
                        var data = eval(xhr.responseText);
                        var str = '';
    
                        if (data.length == 0){
                           str = '<div><div> 暂无更多评论 </div><div><form name="dform"><input class="form-control" type="text"><div class="mt10"></div><button class="btn btn-sm btn-primary" answer_id="'+aid+'" onclick="return discussIn(this)">提交</button><button type="reset" class="btn btn-sm btn-default">重置</button></form></div></div>';
                        } else {

                            for (var i = 0; i < data.length; i++) {
                                str += '<div class="mt10"><div class="w10 pull-left"><a href="/Home/People/index/uid/'+data[i]['duid']+'"><img src="/Public/imgs/'+data[i]['uimg']+'" style="height:25px;width:25px;"></a></div><div class="w90 pull-right"><p class="h6"><a href="/Home/People/index/uid/'+data[i]['duid']+'">'+data[i]['uname']+'</a>';
                                if (data[i]['tuname'] != null) {
                                   str += '回复<a href="/Home/People/index/uid/'+data[i]['tuid']+'">' + data[i]['tuname'] + '</a>';
                                };

                                str += '</p><p style="font-size:10px;">'+data[i]['dcontent']+'</p><p><a href="" style="font-size:10px;" onclick="return replyd(this)" discuss_id="'+data[i]['did']+'" tuid="'+data[i]['duid']+'">回复</a>&nbsp;&nbsp;&nbsp;<a href="" style="font-size:10px;" discuss_id="'+data[i]['did']+'"  tuid="'+data[i]['duid']+'" onclick="return reportd(this)">举报</a> &nbsp;&nbsp; <span>'+data[i]['dtime']+'</span></p>';
                                str += '<div style="display: none"><form name="drform'+i+'"><input class="form-control" type="text"><button onclick="return replyIn(this)" class="btn btn-sm btn-primary" page="1" answer_id="'+aid+'" tuid="'+data[i]['duid']+'" >提交</button><button type="reset" class="btn btn-sm btn-default">重置</button></div></div></form><div class="clearfix"></div><div class="mt10"></div><div class="divline"></div></div>';


                            }; //end for循环
                            str += '<div><form name="dform"><input class="form-control" type="text"><div class="mt10"></div><button class="btn btn-sm btn-primary" answer_id="'+aid+'" page="1" onclick="return discussIn(this)">提交</button><button type="reset" class="btn btn-sm btn-default">重置</button></form><div class="mt10"></div><button class="btn btn-sm btn-default form-control" onclick="disMore(this)" page="'+(parseInt(page)+1)+'" answer_id="'+aid+'">显示更多</button><div class="mt20"></div></div>';
                        }
                        disdiv.innerHTML = str;
                    }; // end  成功接收数据判断
                }; //end 回调
                //初始化
                xhr.open('get', "<{:U('Index/getdiscuss')}>?aid="+aid+"&page="+page, true);
                //发送
                xhr.send();

                disdiv.style.display = 'block';
            } else {
                disdiv.style.display = 'none';
            };  
            return false;
        };

        // 评论显示更多的函数
        function disMore(more){
            showDiscuss(more);
            showDiscuss(more);
        }


        // 原生js写评论的表单事件 
        // 展开回复用户评论
        function replyd(data){
            // console.log(data.parentNode.nextSibling);
            if (data.parentNode.nextSibling.style.display == 'none') {
                data.parentNode.nextSibling.style.display = "block";
            } else {
                data.parentNode.nextSibling.style.display = "none";
            };
            return false;
        }

        // 举报评论内容
        function reportd(data){
            var discuss_id = data.getAttribute('discuss_id');
            if (confirm('你确定举报此评论?') == true) {
                var xhr = new XMLHttpRequest();
                //回调
                // console.log(discuss_id);
                xhr.onreadystatechange = function(){
                    if (xhr.status == 200 && xhr.readyState == 4) {
                        // console.log(xhr.responseText);
                        data.innerHTML = '-已举报-';
                    }
                }
                //初始化
                xhr.open('post', "<{:U('Index/discussReport')}>", true);
                xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
                //发送
                xhr.send("did="+discuss_id);
            }
            return false;
        }


        // 添加回复
        function replyIn(data){
            var answer_id = data.getAttribute('answer_id');
            var tuid = data.getAttribute('tuid');
            var dcontent = data.previousSibling.value;
            
            if (confirm('确定提交?') == true) {
                var xhr = new XMLHttpRequest();
                //回调
                xhr.onreadystatechange = function(){
                    if (xhr.status == 200 && xhr.readyState == 4) {
                        // console.log(xhr.responseText);
                        if (xhr.responseText > 0) {
                            alert('回复成功!');
                            data.previousSibling.value = '';
                            data.parentNode.parentNode.style.display = 'none';
                            showDiscuss(data); //调用两次 一次隐藏 一次显示
                            showDiscuss(data);
                        } else {
                            alert('回复失败!')
                        };
                    }
                }
                //初始化
                xhr.open('post', "<{:U('Index/addReply')}>", true);
                xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
                //发送
                xhr.send("aid="+answer_id+'&tuid='+tuid+'&dcontent='+dcontent);
            }
            return false;
        }


        // 添加评论
        function discussIn(data){
            var answer_id = data.getAttribute('answer_id');
            var dcontent = data.previousSibling.previousSibling.value;
            
            if (confirm('确定提交?') == true) {
                var xhr = new XMLHttpRequest();
                //回调
                xhr.onreadystatechange = function(){
                    if (xhr.status == 200 && xhr.readyState == 4) {
                        // console.log(xhr.responseText);
                        if (xhr.responseText > 0) {
                            alert('评论成功!');
                            data.previousSibling.value = '';
                            // data.parentNode.parentNode.style.display = 'none';
                            showDiscuss(data); //调用两次 一次隐藏 一次显示
                            showDiscuss(data);
                        } else {
                            alert('评论失败!')
                        };
                    }
                }
                //初始化
                xhr.open('post', "<{:U('Index/addDiscuss')}>", true);
                xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
                //发送
                xhr.send("aid="+answer_id+'&dcontent='+dcontent);
            }
            return false;
        }



    </script>

    <block name="myjs"></block>

</body>
</html>